{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4ae5e056",
   "metadata": {},
   "source": [
    "（三）输入三个整数x,y,z；请把这个三个数由小到大输出\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "5739b559",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input:256\n",
      "input:855\n",
      "input:654\n",
      "None\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[256, 654, 855]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_list = []\n",
    "for i in range(3):\n",
    "    x = int(input('input:'))\n",
    "    my_list.append(x)\n",
    "print(my_list.sort())\n",
    "my_list"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "104bc1d2",
   "metadata": {},
   "source": [
    "（四）将一个列表的数据复制到另一个列表中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ca8662d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a =[1,2,3]\n",
    "b =a[:]\n",
    "b"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "862f9d70",
   "metadata": {},
   "source": [
    "(五)暂停一秒输出，并格式化当前时间。使用time模块的sleep()函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "03ee5f69",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2025-04-03- 21:31:11\n",
      "2025-04-03- 21:31:12\n",
      "2025-04-03- 21:31:13\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "print(time.strftime('%Y-%m-%d- %H:%M:%S',time.localtime(time.time())))\n",
    "time.sleep(1)\n",
    "print(time.strftime('%Y-%m-%d- %H:%M:%S',time.localtime(time.time())))\n",
    "time.sleep(1)\n",
    "print(time.strftime('%Y-%m-%d- %H:%M:%S',time.localtime(time.time())))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea783a38",
   "metadata": {},
   "source": [
    "（六）打印出所有的“水仙花数”，所谓“水仙花数”是指一个三位数，其各位数字立方和等于该数本身。例如：153是一个“水仙花数”，因为153=1的三次方+5的三次方+3的三次方。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "83308b00",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "153\n",
      "370\n",
      "371\n",
      "407\n"
     ]
    }
   ],
   "source": [
    "for x in range(1,10):\n",
    "    for y in range(0,10):\n",
    "        for z in  range(0,10):\n",
    "            s1 = x*100+y*10+z\n",
    "            s2 = pow(x,3) +pow(y,3)+pow(z,3)\n",
    "            if s1 == s2:\n",
    "                print(s1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a1253a1",
   "metadata": {},
   "source": [
    "(七)输入一行字符，分别统计出其中英文字母、空格、数字和其它字符的个数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "68d032e1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "inputDo you space English%%%@@\n",
      "char =17,spcae =0,digit = 3,others = 5\n"
     ]
    }
   ],
   "source": [
    "s = input('input')\n",
    "letters =0\n",
    "space =0\n",
    "digit =0\n",
    "others =0\n",
    "for c in s:\n",
    "    if c.isalpha():\n",
    "        letters +=1\n",
    "    elif c.isspace():\n",
    "        digit +=1\n",
    "    else:\n",
    "        others +=1\n",
    "        \n",
    "print('char =%d,spcae =%d,digit = %d,others = %d'%(letters,space,digit,others))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d5b05a0",
   "metadata": {},
   "source": [
    "(八)一球从100米高度自由落下，每次落地后反弹回原高度的一半，求它在第10次落地时，共经过多少米？第10次反弹高度？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "53dfcf43",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.09765625\n",
      "299.609375\n"
     ]
    }
   ],
   "source": [
    "h =100 #总高度\n",
    "time =10 #次数\n",
    "height = [] # 反弹高度\n",
    "for i in range(2,time+1):\n",
    "    h /=2\n",
    "    height.append(h)\n",
    "print(min(height)/2)\n",
    "print(sum(height)*2 +100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "252357cd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
